<?php

namespace Mp\Controller;

use Think\Controller;
use Common\Service\MerUserService;
use Common\Service\MerUserAddressService;

class OrderController extends Controller {

  public function index() {
    $openid = I('get.openid');
    $merid = I('get.merid');
    $MerUserService = MerUserService::instance();
    $mer = $MerUserService->get_user_by_fw_open_id($merid, $openid);
    $userid = 0;
    if (empty($mer)) {
      $userid = $MerUserService->create(array(
        "mer_id" => $merid,
        "fw_open_id" => $openid
        ), false);
    } else {
      $userid = $mer ["id"];
    }
    $MerUserAddressService = MerUserAddressService::instance();
    $data = array(
      'address' => $MerUserAddressService->get_by_cond(array(
        "mer_user" => $userid
      )),
      'add_address' => site_url('/Mp/add_address'),
      'add_order' => site_url('/Mp/add_order')
    );
    $this->assign($data);
    $this->display();
  }

  public function add_address() {
    
  }

  public function add_order() {
    
  }

}
